//---------------------------------------------------------------------------

#ifndef BaseSystemH
#define BaseSystemH
//---------------------------------------------------------------------------


class BaseObject;



/// Declare an abstract class @a type derived from the class @a super.
///
/// @code
/// class MyClass : public EngineObject
/// {
///     DECLARE_ABSTRACT_CLASS( MyClass, EngineObject );
/// };
/// @endcode
///
/// @param type C++ class type.
/// @param super C++ class type of the superclass.  May be void only for EngineObject.
///
/// @see IMPLEMENT_NONINSTANTIABLE_CLASS
#define DECLARE_ABSTRACT_CLASS( type, super )                                          \
   public:                                                                             \
      typedef type ThisType;                                                           \
      typedef super SuperType;                                                         \
      template< typename T > friend struct ::_EngineTypeTraits;                        \
      template< typename T > friend struct ::_SCOPE;                                   \
      template< typename T > friend T* _CREATE();                                      \
      template< typename T, typename Base > friend class ::EngineClassTypeInfo;        \
   private:                                                                            \
      typedef ::_Private::_AbstractClassBase< ThisType > _ClassBase;                   \
      static EngineClassTypeInfo< ThisType, _ClassBase > _smTypeInfo;                  \
      static EngineExportScope& __engineExportScope();                                 \
      static EnginePropertyTable& _smPropertyTable;                                    \
      virtual const EngineTypeInfo* __typeinfo() const;                                \
   public:





/// Assign the current class and all its subclasses to the given export scope.
/// May be overridden by subclasses.
///
/// @code
/// class MyClass : public EngineObject
/// {
///     DECLARE_CLASS( MyClass, EngineObject );
///     DECLARE_INSCOPE( MyAPI );
/// };
/// @endcode
#define DECLARE_INSCOPE( name )                                                        \
   typedef name __DeclScope;



#define DEFINE_CREATE_METHOD                                                           \
      template< typename T >                                                           \
      static T* __create()

// Our backdoor into calling the __create method on any class even if it is
// protected or private.  This function is automatically made friends of any
// EngineObject class.  Should be used except by internal API code.
template< typename T >
inline T* _CREATE()
{
   return T::template __create< T >();
}





class BaseObject
{

protected:

  DEFINE_CREATE_METHOD
  {
     T* object = new T;
     object->incRefCount();
     return object;
  }

public:
  BaseObject();
  virtual ~BaseObject();



};

#endif
